package com.cafe.pro.service;

import com.cafe.pro.entity.User;
import com.cafe.pro.mapper.UserMapper;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
@Slf4j
public class UserService {
    @Autowired
    private UserMapper userMapper;

    public List<User> listUsers() {
        log.info("查询所有用户");
        return userMapper.selectList(null); // 查询所有用户
    }

    public boolean addUser(User user) {
        return userMapper.insert(user) > 0;
    }

    public User getUserById(Integer id) {
        return userMapper.selectById(id);
    }
}
